//
//  FKCommodityCommentHeader.m
//  HappyTest
//
//  Created by Macbook Pro on 2019/2/16.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKCommodityCommentHeader.h"
#import <JXCategoryView.h>

@interface FKCommodityCommentHeader ()<JXCategoryViewDelegate>

@property (nonatomic, weak) JXCategoryTitleView *categoryView;

@end

@implementation FKCommodityCommentHeader

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setupSubviews];
    }
    return self;
}

- (void)setupSubviews
{
    NSArray *titles = @[@"全部(0)", @"好评(0)", @"中评(0)", @"差评(0)"];
    CGFloat headerH = fk_adjustW(48);
    JXCategoryTitleView *categoryView = [[JXCategoryTitleView alloc] initWithFrame:CGRectMake(0, 0, fkScreenW, headerH)];
    [self addSubview:categoryView];
    self.categoryView = categoryView;
    categoryView.titleSelectedColor = fkMainColor;
    categoryView.delegate = self;
    categoryView.titleColorGradientEnabled = YES;
    categoryView.titles = titles;
    categoryView.titleFont = fk_adjustFont(14);
    categoryView.backgroundColor = [UIColor whiteColor];
    
    UIView *separator = [[UIView alloc] initWithFrame:CGRectMake(0, headerH, fkScreenW, 10)];
    [self addSubview:separator];
}

#pragma mark - JXCategoryViewDelegate
- (void)categoryView:(JXCategoryBaseView *)categoryView didSelectedItemAtIndex:(NSInteger)index
{
    if (self.selectedItemBlock) {
        self.selectedItemBlock(fkFORMAT(@"%zd", index + 1));
    }
}

@end
